import *as API from '../../api/index'
const state = {
    data:[]
}

const mutations ={
    getData(state,res){
        res.info.forEach((item,index)=>{
            let arr =[]
            let newArr = item.typesname.split(",");
            newArr.forEach(item1=>{
                if(arr.indexOf(item1)==-1){
                    arr.push(item1)
                }
            })
            item.typesname = arr 
        })
        state.data = res.info
    }
}
const actions = {
       getDataChange({commit},type){
        return new Promise((resolve,reject)=>{
           API.getTypeBookList({type}).then((re)=>{
                commit('getData',re) 
                // console.log(re)
                resolve(re)
            }) 
        })
         
    }
}
const getters = {

}

export default{
    namespaced:true,
    state,
    actions,
    mutations,
    getters
}